package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.DemandDao;
import cn.gson.springboot.model.mapper.DemandMapper;
import cn.gson.springboot.model.pojos.Demand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DemandService {
    @Autowired
    DemandMapper demandMapper;
    @Autowired
    DemandDao demandDao;

    public List<Demand> selectEmpDemand(Integer deptId,Integer filter,Integer vague,String content){
        return  demandMapper.selectEmpDemand(deptId,filter,vague,content);
    }

    public List<Demand> selectDemandByOppId(Integer oppId){
        return demandMapper.selectDemandByOppId(oppId);
    }

    @Transactional(transactionManager = "transactionManager")
    public void saveDemand(Demand demand){
        demandDao.save(demand);
    }

    @Transactional(transactionManager = "transactionManager")
    public void deleteDemand(Integer demandId){
        demandDao.deleteById(demandId);
    }
}
